<?php defined('SYSPATH') or die('No direct script access.'); ?>

<?php echo Form::open('admin/merchmanagement/categories/add/0');?>
<?php echo Form::input('name', '');?>
<?php echo Form::submit('submit', 'Add Root Category') ?>
<?php echo Form::close();?>


<?php foreach($categories as $category) : ?>
<h3><?php echo $category->name;?>
<?php echo HTML::anchor('admin/merchmanagement/delete/'.$category->id, "Delete");?></h3>
<!--
<tr>
<th>Subcategory</th>
<th>Actions</th>
</tr>
-->
		<?php echo Form::open('admin/merchmanagement/add/'.$category->id)?>
		<?php echo Form::input('name', '');?>
		<?php echo Form::submit('submit', 'Add Subcategory');?>
		<?php echo Form::close();?>
<table>
		<?php foreach($category->subcategories->order_by('name', 'asc')->find_all() as $sub): ?>
		<tr>
		<td>
			<?php echo $sub->name; ?>
		</td>
		<td>
			<?php echo HTML::anchor("admin/merchmanagement/delete/".$sub->id, "Delete");?>
			<?php echo HTML::anchor('admin/merchmanagement/attributes/'.$sub->id, 'Manage Attributes');?>
			<?php echo HTML::anchor('admin/merchmanagement/items/index/'.$sub->id, 'Manage Items')?>
			<?php echo Html::anchor('admin/merchmanagement/inventory/edit/'.$sub->id, 'Manage Inventory')?>
		</td>
		</tr>
		<?php endforeach;?>
</table>
<?php endforeach;?>